import re
# "sas".replace()
x = "i am a teacher,i am man, and i am 38 years old.I am not a businessman."
pattern = re.compile(r'(?:[^\w]|\b)i(?:[^\w])')
while True:
    result = pattern.search(x)
    # end返回值是到匹配字符的下一位
    if result:
        if result.start(0) != 0:
            x = x[:result.start(0)+1]+'I'+x[result.end(0)-1:]
        else:
            x = x[:result.start(0)]+'I'+x[result.end(0)-1:]
    else:
        break
print(x)